//
//  InvestCellViewModel.swift
//  cxd4iphone
//
//  Created by hexy on 12/10/15.
//  Copyright © 2015 hexy. All rights reserved.
//

import UIKit

let InvestCellReuseID = "InvestCellReuseID"

class InvestCellViewModel: BaseCellViewModel {

    override var reuseId: String {
        
        return InvestCellReuseID
    }
    
    var releaseTime: String {
        
        return "发布时间:\(bidModel.exceptTime!)"
    }
    
    
    var indentImage: UIImage {
        
//        return UIImage(named: "invest_newer")!
        return UIImage.creatImageWithColorAndSize(UIColor.whiteColor(), Size:CGSizeMake(15, 15))
    }
    var progress:Double {
        
        return Double(bidModel.progress) / 100.0
    }
    var percent: String {
        
        return "\(bidModel.progress)%"
    }
    var percentColor: UIColor {
        
        return cpViewEnable ? Define.redColor : Define.lightFontColor
    }
    var cpViewTitle: String {
        
        switch bidModel.status! {
            
            case "recheck":
                return "复合中"
            case "complete":
                return "已完成"
            case "raising":
                return "马上赚钱"
            case "repaying":
                return "还款中"
            default :
                return ""
        }
    }
    var investTimeNum: String {
        
        return "\(bidModel.deadline)"
    }
    var investTimeUnit: String {
        
        return bidModel.unit ?? ""
    }
    var cpViewEnable: Bool {
        
        return bidModel.status! == "raising"
    }
    
    var cpViewState: UIControlState {
        
        return cpViewEnable ? UIControlState.Normal : UIControlState.Disabled
    }
    
//    recheck  ：复核中
//			 complete ：已完成
//			 raising  投标中 可以投资，其他状态都不可以投资
//			 repaying 还款中
    
    var bidModel: BidModel
    
    init(bidModel: BidModel) {
        
        self.bidModel = bidModel
        
        super.init(icon: nil, title: nil, detail: nil, destVC: nil)
    }
}
